<template>
	<div class="zhengtuojianhuo">
		<van-nav-bar :fixed="true" class="navBar" title="复核容器" left-arrow @click-left="$router.go(-1)"></van-nav-bar>




		<div class="goodsFromWarp">

				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">出库容器：</div>
						</div>
						<van-field
							 class="skuInput"
							 clearable
							 v-model="editForm.jhrqid"
							 placeholder="请填写出库容器"
							 @keyup="onEnter($event,do_inputspbarJhrq)"
							 ref="inputField"
						 />

						 <div class="searchBtn">
						 	<button :disabled="isdisabled"  @click.stop="saveGoodsBtn()" >
						 		<van-icon name="search" size="20" color="#1989fa"  />
						 	</button>
						 </div>
				</div>
		</div>


		<div class="table-responsive">
		  <el-table
						border
						header-row-class-name="header-table"
						height="220px"
		        :data="lingquData"
		        style="width: 100%">
					 <el-table-column type="index" 				label="序" 			  width="50" align="center"></el-table-column>
		       <el-table-column prop="jhrq"					label="容器标签"	  width="90" :show-overflow-tooltip="true"> </el-table-column>
		       <el-table-column prop="yn_fuhe"	    label="复核"			  width="60" :show-overflow-tooltip="true" align="center"> </el-table-column>
		       <el-table-column prop="tpack"		    label="总箱"			  width="60" :show-overflow-tooltip="true" align="center"> </el-table-column>
		       <el-table-column prop="tqty"		      label="总箱"			  width="60" :show-overflow-tooltip="true" align="center"> </el-table-column>
		       <el-table-column prop="ck_storeid"		label="门店"			  width="60" :show-overflow-tooltip="true" align="center"> </el-table-column>
		       <el-table-column prop="storename"		label="门店名"			width="100" :show-overflow-tooltip="true"> </el-table-column>
		       <el-table-column prop="qr_status"		label="状态"			  width="60" :show-overflow-tooltip="true"> </el-table-column>
		       <el-table-column prop="fhr"					label="复核人"			width="80" :show-overflow-tooltip="true"> </el-table-column>
		       <el-table-column prop="bill"					label="波次单号"		width="100" :show-overflow-tooltip="true"> </el-table-column>
		 </el-table>
		</div>



		<div style="margin-top: 10px;">
			<van-notice-bar color="#1989fa" background="#ecf9ff" left-icon="info-o">
			 当前容器有{{lingquData.length}}条商品待复核
			</van-notice-bar>
		</div>

		<div class="goodsFromWarp">

				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">复核门店：</div>
						</div>
						<van-field
							 class="skuInput"
							 clearable
							 v-model="editForm.ck_storeid"
							 placeholder="请填写复核门店"
							 @keyup="onEnter($event,do_inputspbar)"
						 />
				</div>
		</div>
	</div>
</template>

<script>

export default {
  name: 'newsfuherongqi',
  data() {
    return {
			editForm:{
				jhrqid:'',
				ck_storeid:'',
			},
			isdisabled:false,
			lingquData:[

			],
			isLingQuVisible:false,
			skuData:[],
			isSkuVisible:false,
			index:0,
			skuRow:{},
			timeoutId: null,
			isMessageVisible:false,
			total:0,
			areElementsSame:''
		};
  },
	computed: {
		 ryuser: function(){
			 return this.GWO(true).gUSER;
		 },
	},
  methods: {
		do_inputspbar(pmtxt){
			console.log(pmtxt)  //扫描枪获取的参数
			this.editForm.ck_storeid = pmtxt
			this.lingquBtn()
		},
		do_inputspbarJhrq(pmtxt){
			this.editForm.jhrqid = pmtxt
			this.saveGoodsBtn()
		},
		lingquBtn(){
			var _self = this;
			_self.total = 0
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_jianhuo',
				'i':this.FNULLE([
				'opmode','Y_FHRQ_qrybill',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				'ck_storeid',this.editForm.ck_storeid,
				])
				},'复核容器查门店',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到复核容器查门店")
					console.log(rtn_json_obj)
					_self.lingquData = rtn_json_obj
					_self.$refs.inputField.focus();
				}
			});
		},
		saveGoodsBtn(){
			var _self = this;
			_self.total = 0
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_jianhuo',
				'i':this.FNULLE([
				'opmode','Y_FHRQ_qryitemid',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				'ck_storeid',this.editForm.ck_storeid,
				'jhrqid',this.editForm.jhrqid,
				])
				},'校验拣货容器',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到校验拣货容器")
					console.log(rtn_json_obj)
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						return
					}else{
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						_self.editStatus()
					}
				}
			});
		},
		editStatus(){
			console.log("容器编号")
			console.log(this.editForm.jhrqid)
			this.lingquData.forEach((row)=>{
				if(this.editForm.jhrqid == row.jhrq){
					console.log(row.jhrq)
					row.yn_fuhe = 'Y'
				}
			})
			this.editForm.jhrqid = ''

			const firstElement = this.lingquData[0].yn_fuhe;
			return this.areElementsSame =  this.lingquData.every(element => element.yn_fuhe === firstElement);
		},
  },
  mounted() {

  },
	components: {

	},
};
</script>

<style lang="scss" scoped>
	// 引入公共样式
	@import '@/assets/css/base.scss';
	@import '@/assets/css/input.scss';
	div.zhengtuojianhuo{
		padding-top: 50px;
	}



	div.carCardWarp{
		width: 94%;
		margin-left: 3%;
		margin-right: 3%;
		margin-top: 20px;
		font-size:20px;
		font-weight: bold;
		div.carCard{
			position: relative;
			border-left: 5px solid #4998FF;
			box-sizing: border-box;
			padding-left: 10px;
			padding-right: 10px;
			border-radius:5px;
			background-color: #fff;
			padding-top: 10px;
			padding-bottom: 10px;
			margin-bottom:15px;
			div.status{
				position: absolute;
				right: 0;
				top: 0;
				width: 65px;
				height: 30px;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
				font-size: 12px;
				border-radius: 0px 10px 0px 10px;
			}
			div.goodRow{
				margin-bottom:8px;
				span{
					display: inline-block;
					width:100px;
				}
			}
			div.goodsTitleRow{
				display: flex;
				width: 100%;
				div.goodsTitleLabel{
					width:100px;
				}
				div.skuNoTitle{
					width: calc(100% - 100px);
				}
			}
		}
	}



	div.table-responsive{
		width: 100%;
		overflow: auto;
	}


	.header-table th{
		background-color: #1989fa !important;
		padding: 0 !important;
	}

	/deep/.el-table th.el-table__cell{
		background-color: #1989fa !important;
		color: #fff !important;
		padding: 8px !important;
		color: #666;
	}


	/deep/.el-table .el-table__cell{
		padding: 2px 0px !important;
	}

</style>
